﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Fengsoft.AIBlog.Web.Models
{
    public class PagerModel
    {
        public int TotalPages
        {
            get
            {
                int result=1;
                if (TotalRecords>0)
                {
                    result=(int)Math.Ceiling((float)TotalRecords/(float)PageSize);
                }
                return result;
            }
        }
        public int PageIndex
        {
            get
            {
                int result=CurrentPage;
                if (CurrentPage>TotalPages)
                {
                    result=TotalPages;
                }
                return result;
            }
        }
        public int Skip
        {
            get
            {
                return PageSize*PageIndex-PageSize;
            }
        }
        public int TotalRecords
        {
            get;
            set;
        }
        public int PageSize
        {
            get;
            set;
        }
        public int CurrentPage
        {
            get;
            set;
        }
        public string SortingFieldParameterName
        {
            get;
            set;
        }
        public string SortingOrderParameterName
        {
            get;
            set;
        }
        public string PageIndexParameterName
        {
            get;
            set;
        }
        public string PageSizeParameterName
        {
            get;
            set;
        }
        public PagerModel()
        {
            SortingFieldParameterName="sidx";
            SortingOrderParameterName="sord";
            PageIndexParameterName="page";
            PageSizeParameterName="rows";
        }
    }
}